package com.four.reimbursemanage.controller;

import com.four.reimbursemanage.common.bean.ResponseData;
import com.four.reimbursemanage.common.controller.BaseController;
import com.four.reimbursemanage.entity.OutmemberApply;
import com.four.reimbursemanage.entity.Payapply;
import com.four.reimbursemanage.entity.Workapply;
import com.four.reimbursemanage.service.OutmemberApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@CrossOrigin
@RequestMapping("/outmemberApply")
public class OutmemberApplyController extends BaseController {
    @Autowired
    private OutmemberApplyService outmemberApplyService;

    /**
     * 查询外聘人员费申请列表
     */
    @GetMapping("/outmemberList")
    public ResponseData<Object> getPayapply(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "outdate",required = false)@DateTimeFormat(pattern = "yyyy-MM-dd") Date outdate,
            @RequestParam(value = "state",required = false) Integer state
    ){
        return returnObject(outmemberApplyService.getOnrePage(pageNum, pageSize,outdate, state));
    }

    /**
     * 查询本人外聘人员费申请列表
     */
    @GetMapping("/selectByNum")
    public ResponseData<Object> getPayapplyUser(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "outdate",required = false)@DateTimeFormat(pattern = "yyyy-MM-dd") Date outdate,
            @RequestParam(value = "state",required = false) Integer state,
            @RequestParam(value = "number",required = false) String number
    ){
        return returnObject(outmemberApplyService.getOnrePageUser(pageNum, pageSize,outdate, state, number));
    }

    /**
     * 新增外聘人员费申请
     */

    @PostMapping("/add")
    public ResponseData<Boolean> add(OutmemberApply outmemberApply)
    {
        return returnBoolean(outmemberApplyService.insertOutmemberApply(outmemberApply));
    }

    /**
     * 修改外聘人员费申请
     */

    @PutMapping("/update")
    public ResponseData<Boolean> edit(@RequestBody OutmemberApply outmemberApply)
    {
        return returnBoolean(outmemberApplyService.updateOutmemberApply(outmemberApply));
    }

    @PutMapping("/updateC")
    public ResponseData<Boolean> updateS(@RequestBody OutmemberApply outmemberApply)
    {
        return returnBoolean(outmemberApplyService.updateC(outmemberApply));
    }
}
